<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>GoLogin</title>

    <!-- icon小图标 -->
	<link rel="icon" href="../statics/images/icon_S_Bar_Contact.png" type="image/x-icon">
    <!-- Bootstrap -->
    <link rel="stylesheet" href="/statics/css/bootstrap.min.css">
    <!-- 演讲隐藏显示 -->
    <link rel="stylesheet" href="/statics/css/log_register/leaf.css">
    <!-- 登录-样式 -->
    <link rel="stylesheet" href="/statics/css/log_register/login_in.css">

</head>
<!-- body...键盘回车键登录注册 -->
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onkeydown="on_return();">
    <!-- 开始代码 -->
    <!-- 提示弹出框 ------------------------------------------------------------------------->
    <div class="col" style="width: 30rem;height: 6rem; margin: 0 auto;">
        <div class="alert alert-dark alert-dismissible fade show invisible" role="alert">
            <div class="modal-headers">
                <strong class="alert-dan">localhost 提示:</strong>
                <hr>
                <label for="" id="msgId">good nice</label>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-sm">

        </div>
        <div class="col-sm">

            <!-- <div class="meizuLogo">
                <div id="fh5co-logo">
                    <a href="#">
                        <button type="button" class="btn btn-outline" style="width: 5.5rem;" name="reset"><img
                                src="/statics/images/log_register/log_regis/管理员.png" border="0" width="80" height="35"
                                title="管理员"></button>
                    </a>
                </div>
            </div> -->

            <div class="trigger">
                <h4 class="tri_good">
                    <a href="##">登录</a>
                    <span>&nbsp;|&nbsp;</span>
                    <a href="##">注册</a>
                </h4>
            </div>
        </div>
        <div class="col-sm">

        </div>
    </div>
    <!-- 栅栏样式 ----------------------------------------------------------------------->
    <div class="container">
        <div class="col-sm">

        </div>
        <div class="col-sm shadow"
            style="height: 25rem;border-radius: 0.5rem;background:rgba(252, 250, 244, 0.090);box-shadow: 7px 7px 17px rgba(52, 56, 66, 0.5);">
            <form id="loginForm" action="/loginDone" method="POST">
                <!-- top -->
                <div id="title">
                    <!-- 是否为管理员框 -->
                    <!-- <div class="field">
                        请选择您的身份: <select name="rolename">
                            <option value="0">一般管理员</option>
                            <option value="1">超级管理员</option>
                        </select>
                    </div> -->
                    <!-- 登录标题 -->
                    <p><img src="../statics/images/log_register/log_regis/login.png" alt="" width=92.8; height="40"></p>
                </div>

                <div id="body_middle">

                    <!-- 账号框 -->

                    <!-- 账号框 -->
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                            <span class="input-group-text" id="basic-addon1"><img src="../statics/images/log_register/log_regis/用户名.png" alt="" width=20; height="20"></span>
                        </div>
                        <input class="form-control" name="username" type="text" id="username" placeholder="请输入用户名">
                    </div>
                    <!-- 密码框 -->
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                            <span class="input-group-text" id="basic-addon1"><img src="../statics/images/log_register/log_regis/密码.png" alt="" width=20; height="20"></span>
                        </div>
                        <input class="form-control" name="password" type="password" id="password" placeholder="请输入密码">
                        <!-- 功能小眼睛 -->
                        <img src="../statics/images/log_register/log_regis/eye-slash.svg" alt="" id="eyes" style="position: absolute;right: 1rem;top:0.7rem;">
                    </div>
                    <!-- 记住、登录注册框 -->
                    <div class="btn-losa">
                        <div class="form-group-3 form-check">
                            <input type="checkbox" class="form-check-input" id="exampleCheck1">
                            <label class="form-check-label" for="exampleCheck1">
                                <h6>Remember Me</h6>
                            </label>
                            <a href="">忘记密码？</a>
                        </div>
                        <div class="form-group-5">
                            <input class="btn btn-outline-success" type="button" id="sub" value="登录" onclick="jump()" />
                            <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                            <input class="btn btn-outline-success" type="reset" value="重置" />
                        </div>
                    </div>
                </div>
                <!-- 点击 --------------------------------------------------------------->
                <div class="rememberField">
                    <label class="pointer">没账号噢</label>
                    <a href="/register" target="_blank" class="linkABlue">点我注册吧</a>
                </div>
            </form>
        </div>
        <div class="col-sm">

        </div>

    </div>
    <!-- 背景特效 -->
    <script async type="text/javascript" size="90" alpha="0.2" zIndex="0" src="/statics/js/wall_paper/ribbon.js"></script>
    <!-- jquery -->
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
    <!-- axios -->
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>

    <script>
        // 注册跳转
        function register() {
            window.location.href = '/register';
        }
        function jump() {
            // 获取表单数据
            let uid = $('#username').val();
            let pwd = $('#password').val();

            // 判断用户名、密码是否为空，为空则提示；不为空则向服务器提交
            if (uid.length > 0 && pwd.length > 0) {
                axios({
                    method: 'post',
                    url: '/loginDone',
                    data: $('#loginForm').serialize(),
                }).then(function (res) {
                    // axios工具下，服务器真正返回的数据在返回对象的data中
                    res = res.data;
                    if (res.code === 200) {
                        window.location.href = '/';
                    } else {
                        alert_fn(res.msg);
                        console.log(res.msg);
                    }
                }).catch((err) => {
                    alert_fn(err);
                    console.log(err);
                });
            } else {
                alert_fn('用户名、密码不能为空');
            }
        }
        // 包装了显示（以及自动隐藏）消息警告的动作
        function alert_fn(msg) {
            $('#msgId').text(msg);
            $('.alert').removeClass('invisible');
            setTimeout(() => {
                $('.alert').addClass('invisible');
            }, 3000);
        }
        //回车时，默认是登陆
        function on_return() {
            if (window.event.keyCode == 13) {
                if (document.all('sub') != null) {
                    document.all('sub').click();
                }
            }
        }
    </script>
    <!-- Bootstrap -->
    <script src="/statics/js/bootstrap.min.js"></script>
    <!-- jquery -->
    <script src="/statics/js/log_register/jquery-3.5.1.min.js"></script>
    <!-- icon_click眼睛样式 -->
    <script src="/statics/js/log_register/icon_click.js"></script>

    <!-- 结束代码 -->
</body>

</html>